<{include file="admin/head.html"}>
<link rel="stylesheet" href="<{$smarty.const.__URL__}>plugins/tablecloth/tablecloth.css">
<body>
	<{include file="admin/nav.html"}>
	<div id="content">
		<div id="sidebar">
			<ul>
				<li><a href="index.php">后台首页</a></li>
				<li><a href="index.php?do=nav">导航管理</a></li>
		</div>
		<div id="main">
			<h2 id="page_title">导航管理</h2>
				<{if $list}>
				<table>
					<tr>
						<th>ID</th>
						<th>名称</th>
						<th>链接</th>
						<th>排序</th>
						<th style="width:90px;">操作</th>
					</tr>
					<{foreach from=$list item=l}>
					<tr id="row_<{$l.id}>">
						<td class="cell_id"><{$l.id}></td>
						<td class="cell_title"><{$l.title}></td>
						<td class="cell_url"><a href="<{$l.url}>" title="跳转" target="_blank">跳转</a></td>
						<td class="cell_sort"><{$l.sort}></td>
						<td>
							<a href="javascript:;" class="ln_edit" data="<{$l.id}>">修改</a>
							<a href="javascript:;" class="ln_del" data="{'url':'index.php?do=delNav&id=<{$l.id}>','to':'index.php?do=nav'}">删除</a>
						</td>
					</tr>
					<{/foreach}>
				</table>
				<{else}>
					<div class="no_data">暂无数据</div>
				<{/if}>
				<div class="multi_op_form">
					<form method="post" enctype="multipart/form-data">
						<fieldset>
							<legend>添加导航</legend>
							<div class="row">
								<label for="name" class="row_left">名称</label>
								<input id="txt_name" type="text" name="title" class="row_right">
							</div>
							<div class="row">
								<label class="row_left">链接</label>
								<div class="row_right">
									<input type="text" id="txt_url">
									或
									<select id="sel_url">
										<option value="0">链接到分类</option>
										<{foreach from=$cats item=c}>
										<option value="<{$smarty.const.__URL__}>category.php?id=<{$c.id}>"><{$c.name}></option>
										<{/foreach}>
									</select>
									<input type="hidden" name="url" id="url">
								</div>
							</div>
							<div class="row">
								<label class="row_left">排序</label>
								<div class="row_right">
									<input type="text" name="sort" value="1">
								</div>
							</div>
							<div class="row">
								<input type="submit" value="提交" name="submit">
								<input id="btn_reset" type="reset" value="重置">
								<input id="do" type="hidden" name="do" value="<{$do|default:'addNav'}>">
								<input id="txt_id" type="hidden" name="id" value="<{$id}>">
							</div>					
						</fieldset>
					</form>
				</div>
		</div>
	</div>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#txt_url').blur(function(){
			if( $(this).val()!="" ){
				$('#sel_url').val(0);
				$('#url').val($(this).val());
			}
		}).focus(function(){
			$(this).removeAttr('style')
		})
		$('#sel_url').change(function(){
			if( $(this).val()!='' ){
				$('#txt_url').attr('style','background:#DEDEDE');
				$('#url').val($(this).val());
			}
		})
		$('.ln_edit').click(function(){
			var id = $(this).attr('data');
			var ntitle = $('#row_'+id+' .cell_title').text();
			var url = $('#row_'+id+' .cell_url a').attr('href');
			$('#txt_id').val(id);
			$('#txt_name').val(ntitle);
			$('#url,#txt_url').val(url);
			$('#do').val('editNav');
			$('.multi_op_form form').css('background','#BCE774');
			$('.multi_op_form legend').text('修改分类');
			setTimeout(function(){$('.multi_op_form form').css('background','');},300)
		})
		$('#btn_reset').click(function(){
			$('#do').val('addNav');	
			$('.multi_op_form legend').text('添加分类');
		})
	})
	</script>
</body>
</html>	